A comparator reduces a continuous voltage to a binary decision against a fixed reference. A timer converts an interval into a signal: either a single pulse of chosen duration, or a square wave at a chosen rate. Together these two blocks form the interface between the analog front end and the digital domain, and appear in almost every measurement instrument and stimulator. The scenes below illustrate six canonical uses; the underlying circuits and design equations are derived in the pages that follow.
A lithium-ion cell suffers permanent damage when it is discharged below approximately $3.0\,\mathrm{V}$. Wearable monitors, implanted pumps, and portable defibrillators therefore include a dedicated comparator whose role is to disconnect the load before this limit is reached.
The panel below traces the cell voltage as it discharges under load. A comparator continuously evaluates whether $V_\mathrm{cell}$ exceeds the cutoff and drives a single binary output to a power-path switch. While the cell remains above the threshold the load stays connected; once it falls below, the comparator flips and the switch opens.
Drag the dashed red line to change the cutoff voltage and observe the moment of disconnection.
A bedside heart-rate monitor reports beats per minute, but its input is a continuous analog ECG. A comparator performs the conversion from waveform to beat. With its threshold placed above the T-wave but below the R-peak, the comparator emits one clean digital pulse on every upward crossing, and a downstream counter divides by the window length to obtain the rate.
Drag the red threshold line to adjust where the comparator fires. If it is set too low, T-waves and noise are counted as beats; if too high, real R-peaks are missed. The same arrangement appears in pulse oximeters, oscillometric blood-pressure cuffs, and event-driven sleep monitors.
A photoresistor or photodiode produces a voltage proportional to incident light. A comparator placed at its output reduces the continuous reading to a binary day/night decision. The same circuit appears in automatic headlights, in the ambient sensor of a phone display, and in the standby logic of pulse-oximetry probes that sample only when a finger is present on the lens.
Drag the sun across the sky to vary the sensor voltage. When it falls below the dusk threshold, the comparator output goes high and the lamp switches on. The threshold marker on the right-hand bar sets how dark the scene must become before activation.
An implanted pacemaker delivers a brief electrical pulse to the heart at a controlled rate. The timer decides when to fire, emitting one pulse of fixed width each time its internal interval expires. Pulse amplitude is set by a separate output stage; the timer concerns itself only with scheduling.
The same primitive appears in transcutaneous nerve stimulators (TENS), in cochlear implants that drive electrode arrays in synchrony, and in retinal prostheses. In every case the clinician selects a rate and a pulse width, and the timer renders those parameters as a periodic waveform.
Use the sliders to set the pacing rate and the pulse width. Each pulse corresponds to one paced heartbeat.
A timer that produces a square wave at fixed frequency but adjustable on-time can regulate average power without dissipating heat in a series resistance. The load sees the full supply during the on-interval of each cycle and zero during the off-interval, so its time-average is the supply voltage scaled by the duty cycle $D$.
The same primitive dims a phototherapy LED panel without colour shift, sets the motor speed of a syringe pump, and regulates the backlight of a clinical display. Class-D audio amplifiers apply it at a much higher carrier frequency to drive a speaker.
Move the duty-cycle slider and observe the load brightness track the time-average of the square wave. The lower plot traces the steady-state envelope of delivered power against PWM frequency: the green line is the time-average $D \cdot V_{cc}$, independent of frequency, and the shaded band is the peak-to-peak ripple at the bulb, modelled as a first-order thermal load with $\tau = 50\,\mathrm{ms}$. The live bulb at the right is driven by exactly this filtered waveform.
When a mechanical key is pressed, the metal contacts do not close cleanly. They strike, separate, and continue to bounce for several milliseconds before settling. To a digital input every closure appears as a fresh keypress, so one physical touch produces a burst of phantom characters.
The standard remedy is an $RC$ low-pass feeding a Schmitt-trigger comparator. The capacitor voltage obeys $\tau\,\dot V_C = V_\mathrm{in} - V_C$ with $\tau = RC$, so $V_C$ cannot follow the bouncing input directly; instead it integrates the burst. The Schmitt output goes high when $V_C$ crosses the upper threshold $V_{T+}$ and only resets after $V_C$ falls below the lower threshold $V_{T-}$. Choosing $\tau$ longer than the bounce interval guarantees that $V_C$ crosses $V_{T+}$ exactly once per physical press.
Click the input textbox and start typing. Each keypress is replaced by a realistic burst of contact bounces. The lower trace shows $V_C(t)$ integrating that burst, with the dashed band marking the Schmitt hysteresis window. Every $\mathrm{LOW}\!\to\!\mathrm{HIGH}$ crossing emits one character on the line; the tick above each crossing is green for the intended press and red for any phantom. At $T_d = 0$ the cap follows the bounces almost perfectly and many phantoms appear; raising $T_d$ (which sets $\tau = T_d$) smooths $V_C$ and removes them.